import java.util.Iterator;
import java.util.List;

public class demo1 {
    //不可变的list集合，一旦创建完毕无法修改，在下面得代码只能进行查询操作

    public static  void main(String[] args){

        List<String >  list=List.of("张三","李四","王五");

        System.out.println(list.get(0));
        System.out.println(list.get(1));

        for (String s : list) {
            System.out.println(s);
        }
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){

            String s= iterator.next();
            System.out.println(s);
        }
        //无法对集合进行进行修改会抛出异常
         // list.remove("李四");
         //list.add("天龙");
         //list.set(0,"幻灭");

    }



}
